Rules Manager for WPF | ComponentOne
Working With Rules / Load, Save and Delete Rules
In This Topic
    Load, Save and Delete Rules
    In This Topic

    Load and Save Rules

    Rules Manager supports loading and saving rules to an XML file. It allows loading of rule definitions using the Load method of the C1RulesManager class. The Load method takes Stream as parameter to load the rules. Similarly, Rules Manager enables saving of the rules definition using the Save method of the C1RulesManager class. The Save method takes Stream as parameter to save the rules.

    Delete a Rule

    To delete a rule programmatically, use the following code.

    C#
    Copy Code
    // Remove a rule with a specific expression
    var ruleToRemove = rulesManager.Engine.Rules
        .OfType<RulesEngineExpressionRule>()
        .FirstOrDefault(r => r.Expression == "[OrderCount] < 50");
     if (ruleToRemove != null)
     {
         //Code to remove the rule
         rulesManager.Engine.Rules.Remove(ruleToRemove);
     }